
<template>
  <ex_super_input :value="value" type="select" :attrs="{
    url: url,
    urlParams: getUrlParams, storeData: true, filterable: true,
    option: optionBuild,
  }" v-bind="$attrs" v-on="$listeners" :disabled="disabled" />
</template>

<script>
import role_system_mixin from '@/mixin/role_system_mixin';

export default {
  name: 'base_warehouse_select',
  mixins: [role_system_mixin,],

  data() {
    return {
      url: ''
    }
  },
  props: {
    value: null,

    disabled: Boolean,
    isEnable: {
      type: Boolean,
      default: null
    },
    // 指定 查询中转或非中转仓，不指定则查询全部
    isTransit: {
      type: Boolean,
      default: null
    },
  },
  created() {
    if (this.isOmsSystem) {
      this.url = "/oms-api/base/OmsBaseWarehouseRpc/selectAllLabel.json"
    } else if (this.isCustomerSystem) {
      this.url = "/oms-api/client/OmsBaseWarehouseClientRpc/selectAllLabel.json"
    }
  },
  methods: {
    optionBuild(item) {
      return { label: this.$formatNameCode(item.name, item.code), value: item['id'] }
    },
    getUrlParams() {

      const params = {}

      if (this.isEnable == true) {
        params.isEnable = "ENABLE"
      } else if (this.isEnable == false) {
        params.isEnable = "DISABLED"
      }
      if (this.isTransit == true) {
        params.isTransit = "Y"
      } else if (this.isTransit == false) {
        params.isTransit = "N"
      }
      return params
    }
  },
}
</script>
